//
//  SINAActivityTargetDesViewController.m
//  PlanTech
//
//  Created by  androidlongs on 2018/6/28.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINAActivityTargetDesViewController.h"
#import "SINACircularBeadUtils.h"
#import "SINACalendarUtils.h"
#import "HWCircleView.h"
#import "SINAStuTargetFinishPopView.h"

@interface SINAActivityTargetDesViewController ()
@property(strong,nonatomic)UIButton *commitButton;
@property(strong,nonatomic)UIImageView *targetCirStatueImagView;
@property(strong,nonatomic)UIImageView *targetCirBgImagView;
@property(strong,nonatomic)UIImageView *targetLevelCirBgImagView;
@property(assign,nonatomic) NSInteger currentAlertStatue;

@property (nonatomic, weak) HWCircleView *circleView;

@property (nonatomic, strong) NSTimer *timer;

@property (nonatomic,assign) NSInteger useTotalTime;
@property(strong,nonatomic) UILabel *useTimeLabel;

@property(assign,nonatomic) NSInteger activityTagetEndTime;

@end

@implementation SINAActivityTargetDesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initTimeDataFunction];
    [self initViewFunction];
}
-(void)initTimeDataFunction{
    if (self.itemModel.plantime!=nil&&![self.itemModel.plantime isEqualToString:@""]) {
        if ([self.itemModel.plantime isEqualToString:@"1min"]) {
            self.useTotalTime =1;
        }else  if ([self.itemModel.plantime isEqualToString:@"5min"]) {
            self.useTotalTime =5;
        }else  if ([self.itemModel.plantime isEqualToString:@"10min"]) {
            self.useTotalTime =10;
        }else  if ([self.itemModel.plantime isEqualToString:@"30min"]) {
            self.useTotalTime =30;
        }else  if ([self.itemModel.plantime isEqualToString:@"1hour"]) {
            self.useTotalTime =60;
        }else  if ([self.itemModel.plantime isEqualToString:@"2hour"]) {
            self.useTotalTime =120;
        }
    }
}
- (void)addTimer
{
    NSInteger activityStartTime = [self.activityModel.activityStartTime integerValue];
    NSInteger activityEndTime = [self.activityModel.activityStopTime integerValue];
    //当前时间
    NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
    
    if (currentTime<activityStartTime) {
        DLog(@"活动未开始");
    }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
        DLog(@"活动中");
    }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
        //活动结束 以及结束后的半小时
    }else{
        //超时
        [self stopAnimation];
        return;
    }
    _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
    [[NSRunLoop mainRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
}
- (void)removeTimer
{
    if (_timer!=nil) {
        [_timer invalidate];
        _timer = nil;
    }
}
- (void)timerAction
{
    
    
    self.itemModel.useTime+=1000;
    
    DLog(@"已使用时间 %ld",self.itemModel.useTime);
    
    self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
    
    
    if(self.itemModel.plantime!=nil&&![self.itemModel.plantime isEqualToString:@""]){
        
        _circleView.progress =self.itemModel.useTime *1.0f/(self.useTotalTime*60*1000);
        
        if (_circleView.progress >= 1) {
            //[self removeTimer];
            NSLog(@"完成");
            //更新图标
            if (!_circleView.isHidden) {
                _circleView.hidden=YES;
                self.targetCirBgImagView.image=[UIImage imageNamed:@"target_over_time_bg"];
                self.useTimeLabel.textColor=[UIColor colorWithHexString:@"#17ff17"];
                [self startAnimationWithFlag:2];
            }
            
        }else{
            if (_circleView.hidden==YES) {
                self.useTimeLabel.textColor=[UIColor whiteColor];
                _circleView.hidden=NO;
            }
        }
        
    }else{
        
        _circleView.hidden=YES;
        
    }
    
}

-(void)initViewFunction{
    UIView *headerView = [[UIView alloc]init];
    [self.view addSubview:headerView];
    headerView.backgroundColor=[UIColor clearColor];
    
    
    
    if (IS_IPHONE_X) {
        headerView.frame= CGRectMake(0, 0, mainW, 88);
    } else {
        headerView.frame= CGRectMake(0, 0, mainW, 64);
    }
    
    UIView *backView = [[UIView alloc]init];
    [headerView addSubview:backView];
    backView.frame=CGRectMake(0, 0, 100, CGRectGetHeight(headerView.frame));
    backView.backgroundColor=[UIColor clearColor];
    
    UIImageView *backImageView = [[UIImageView alloc]init];
    backImageView.frame=CGRectMake(14, CGRectGetHeight(backView.frame)-12-20, 12, 20);
    backImageView.image=[UIImage imageNamed:@"back1"];
    [backView addSubview:backImageView];
    
    [[SINAUiviewClickLiserner alloc]viewClickFunction:backView andWithBlick:^(UIView *view) {
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    
    //标题
    UILabel *targetTitleLabel =[[UILabel alloc]initWithFrame:CGRectMake(32, CGRectGetMaxY(headerView.frame)+20, mainW-24-20, 30)];
    targetTitleLabel.font=[UIFont systemFontOfSize:20];
    targetTitleLabel.textColor=[UIColor colorWithHexString:@"#ffffff"];
    targetTitleLabel.text=self.itemModel.title;
    [self.view addSubview:targetTitleLabel];
    
    UILabel *useTimeLabel =[[UILabel alloc]initWithFrame:CGRectMake(32, CGRectGetMaxY(targetTitleLabel.frame)+20, mainW-24-20, 60)];
    useTimeLabel.font=[UIFont systemFontOfSize:62];
    useTimeLabel.textColor=[UIColor colorWithHexString:@"#ffffff"];
    useTimeLabel.text=@"00:00:00";
    self.useTimeLabel=useTimeLabel;
    [self.view addSubview:useTimeLabel];
    
    if (self.itemModel.useTime==0) {
        useTimeLabel.text=@"00:00:00";
    }else{
        self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
    }
    
    if (self.itemModel.status==1000) {
        //未开始  显示开始按钮
        useTimeLabel.text=@"00:00:00";
    }else if (self.itemModel.status==1012||self.itemModel.status==1011) {
        //已开始  显示暂按钮
        
        NSInteger activityStartTime = [self.activityModel.activityStartTime integerValue];
        NSInteger activityEndTime = [self.activityModel.activityStopTime integerValue];
        //当前时间
        NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
        
        if (currentTime<activityStartTime) {
            DLog(@"活动未开始");
        }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
            DLog(@"活动中");
        }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
            //活动结束 以及结束后的半小时
        }else{
            //超时
            currentTime =activityEndTime+30*60*1000;;
        }
        
        if (self.itemModel.useTime==0) {
            //未暂停过
            self.itemModel.useTime =currentTime-self.itemModel.startTime;
            self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
        }else{
            //有过暂停时间
            self.itemModel.useTime = self.itemModel.useTime+currentTime-self.itemModel.pauseendtime;
            self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
        }
        
    }else if (self.itemModel.status==1013 ) {
        //已暂住  显示继续按钮
        //一定有暂停时间
        self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
    }else if (self.itemModel.status==1014) {
        //已暂住  显示继续按钮
        //一定有暂停时间
        self.useTimeLabel.text=[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",self.itemModel.useTime/1000]];
    }
    
    
    
    //时间选择背景
    UIImageView *targetCirBgImagView = [[UIImageView alloc]init];
    [self.view addSubview:targetCirBgImagView];
    targetCirBgImagView.image = [UIImage imageNamed:@"target_cir_bg"];
    self.targetCirBgImagView =targetCirBgImagView;
    
    //时间旋转背景
    UIImageView *targetLevelCirBgImagView = [[UIImageView alloc]init];
    [self.view addSubview:targetLevelCirBgImagView];
    targetLevelCirBgImagView.image = [UIImage imageNamed:@"target_cir_leve_bg"];
    self.targetLevelCirBgImagView =targetLevelCirBgImagView;
    
    
    if(self.itemModel.plantime!=nil&&![self.itemModel.plantime isEqualToString:@""]){
        
        //有定时
        self.targetLevelCirBgImagView.hidden=YES;
        
        UILabel *targetLabel =[[UILabel alloc]initWithFrame:CGRectMake(32, CGRectGetMaxY(useTimeLabel.frame)+14, mainW-24-20, 30)];
        targetLabel.font=[UIFont systemFontOfSize:20];
        targetLabel.textColor=[UIColor colorWithHexString:@"#ffffff"];
        targetLabel.text=[NSString stringWithFormat:@"目标:%@", self.itemModel.plantime];
        [self.view addSubview:targetLabel];
        
        targetCirBgImagView.frame = CGRectMake(mainW/2-195/2,CGRectGetMaxY(targetLabel.frame)+60, 195, 195);
    }else{
        self.targetLevelCirBgImagView.hidden=NO;
        //无定时
        targetCirBgImagView.frame = CGRectMake(mainW/2-195/2,CGRectGetMaxY(useTimeLabel.frame)+60, 195, 195);
        self.targetLevelCirBgImagView.frame=CGRectMake(mainW/2-195/2,CGRectGetMaxY(useTimeLabel.frame)+60, 195, 195);
    }
    
    
    HWCircleView *circleView = [[HWCircleView alloc] init];
    circleView.frame =targetCirBgImagView.frame;
    circleView.progressStoreWidth=15;
    circleView.progressColor = [UIColor whiteColor];
    [self.view addSubview:circleView];
    self.circleView=circleView;
    
    
    UIImageView *targetCirStatueImagView = [[UIImageView alloc]init];
    [self.view addSubview:targetCirStatueImagView];
    self.targetCirStatueImagView=targetCirStatueImagView;
    
    [self updateTagerIconFunction];
    
    [[SINAUiviewClickLiserner alloc]viewClickFunction:targetCirStatueImagView andWithBlick:^(UIView *view) {
        [self updateTagterStatueFunction];
    }];
    
    
    
    
    //myWebView.layer.cornerRadius = 8; 
    
    UIButton *commitButton = [[UIButton alloc]init];
    [self.view addSubview:commitButton];
    [commitButton addTarget:self action:@selector(finishTargetFunction) forControlEvents:UIControlEventTouchUpInside];
    commitButton.frame = CGRectMake(14, mainH-14-42-20, mainW-28, 42);
    [commitButton setTitle:@"完成" forState:UIControlStateNormal];
    
    [SINACircularBeadUtils makeBorder:commitButton andWithBorderWidth:1 andBorderRadius:21 andBorderColor:[UIColor whiteColor]];
    
    [commitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [commitButton setTitleColor:baseSelectColor forState:UIControlStateHighlighted];
    
    [commitButton setBackgroundImage:[self imageWithColor:[UIColor clearColor]] forState:UIControlStateNormal];
    [commitButton setBackgroundImage:[self imageWithColor:[UIColor whiteColor]] forState:UIControlStateHighlighted];
    self.commitButton = commitButton;
    
    if (self.itemModel.status ==1011||self.itemModel.status ==1012||self.itemModel.status ==1013) {
        commitButton.hidden=NO;
        NSInteger activityStartTime = [self.activityModel.activityStartTime integerValue];
        NSInteger activityEndTime = [self.activityModel.activityStopTime integerValue];
        //当前时间
        NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
        
        if (currentTime<activityStartTime) {
            DLog(@"活动未开始");
        }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
            DLog(@"活动中");
        }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
            //活动结束 以及结束后的半小时
        }else{
            //超时
            commitButton.hidden=YES;
        }
    }else{
        commitButton.hidden=YES;
    }
    
    
    
}
//更新按钮
-(void)updateTagerIconFunction{
    
    DLog(@"当前活动的状态 %ld",self.itemModel.status);
    if (self.itemModel.status==1000) {
        //未开始  显示开始按钮
        self.targetCirStatueImagView.image = [UIImage imageNamed:@"target_cir_start_bg"];
        self.targetCirStatueImagView.frame =CGRectMake(0, 0, 33, 50);
    }else if (self.itemModel.status==1012||self.itemModel.status==1011) {
        //已开始  显示暂按钮
        self.targetCirStatueImagView.image = [UIImage imageNamed:@"target_cir_pasue_bg"];
        self.targetCirStatueImagView.frame =CGRectMake(0, 0, 44, 47);
        
        //添加定时器
        [self addTimer];
        
        
        [self startAnimationWithFlag:2];
        [self startAnimationWithFlag:1];
        
        
        
    }else if (self.itemModel.status==1013 ) {
        [self removeTimer];
        [self stopAnimation];
        //已暂住  显示继续按钮
        self. targetCirStatueImagView.image = [UIImage imageNamed:@"target_cir_goon_bg"];
        self.targetCirStatueImagView.frame =CGRectMake(0, 0, 64, 62);
    }else if (self.itemModel.status==1014 ) {
        [self removeTimer];
        [self stopAnimation];
        //已结束小目标
        self.targetCirStatueImagView.image = [UIImage imageNamed:@"target_cir_pasue_bg"];
        self.targetCirStatueImagView.frame =CGRectMake(0, 0, 33, 50);
        _circleView.progress=1.0;
    }
    
    
    NSInteger activityStartTime = [self.activityModel.activityStartTime integerValue];
    NSInteger activityEndTime = [self.activityModel.activityStopTime integerValue];
    //当前时间
    NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
    
    if (currentTime<activityStartTime) {
        DLog(@"活动未开始");
    }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
        DLog(@"活动中");
    }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
        //活动结束 以及结束后的半小时
    }else{
        //超时
        [self stopAnimation];
    }
    
    self.targetCirStatueImagView.center=CGRectGetCenter(self.targetCirBgImagView.frame);
//    self.targetCirStatueImagView.center=CGRectGetCenter(self.targetCirBgImagView.frame);
    
}
//更新活动状态
-(void)updateTagterStatueFunction{
    DLog(@"更新活动状态");
    
    
    NSInteger activityStartTime = [self.activityModel.activityStartTime integerValue];
    NSInteger activityEndTime = [self.activityModel.activityStopTime integerValue];
    //当前时间
    NSInteger currentTime = [[SINACalendarUtils currentTimeStr] integerValue];
    
    if (currentTime<activityStartTime) {
        DLog(@"活动未开始");
    }else if(currentTime>=activityStartTime&&currentTime<=(activityEndTime)){
        DLog(@"活动中");
    }else if(currentTime>=activityEndTime&&currentTime<=(activityEndTime+30*60*1000)){
        //活动结束 以及结束后的半小时
    }else{
        //超时
        if (self.itemModel.status!=1014) {
            [YPXToastView showToastViewWithText:@"活动已结束 小目标不可操作" andDuration:3 andParentView:self.view];
            return;
        }
    }
    
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    [dict setObject:self.itemModel.uuid forKey:@"uuid"];
    
    //[dict setObject:[SINACalendarUtils currentTimeStr] forKey:@"endtime"];
    if (self.itemModel.status==1000) {
        //未开始  显示开始按钮  将目标更新为开始状态
        NSString *currentStratTime =[SINACalendarUtils currentTimeStr];
        [dict setObject:currentStratTime forKey:@"starttime"];
        [dict setObject:[NSString stringWithFormat:@"%d",1011] forKey:@"status"];
        self.currentAlertStatue = 1011;
        [self updateTargetTime:dict];
        
    }else if (self.itemModel.status==1011||self.itemModel.status==1012) {
        [self removeTimer];
        //已开始  显示暂按钮  将目标更新为暂停
        [dict setObject:[NSString stringWithFormat:@"%d",1013 ] forKey:@"status"];
        //pausetime
        [dict setObject:[NSString stringWithFormat:@"%ld",self.itemModel.useTime] forKey:@"pausetime"];
        self.currentAlertStatue = 1013;
        [self updateTargetTime:dict];
    }else if (self.itemModel.status==1013) {
        //已暂住  显示继续按钮 将目标更新为继续
        [dict setObject:[NSString stringWithFormat:@"%d",1012  ] forKey:@"status"];
        [dict setObject:[SINACalendarUtils currentTimeStr] forKey:@"pauseendtime"];
        self.currentAlertStatue = 1012;
        [self updateTargetTime:dict];
    }else if (self.itemModel.status==1014) {
        [YPXToastView showToastViewWithText:@"小目标已完成" andDuration:3 andParentView:self.view];
    }
    
    
}
-(void) updateTargetTime:(NSMutableDictionary *) dict{
    
    
    [self startLoading];
    NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
    [dict2 setObject:[SINAHttpRequestUtils encodeDicParams:dict] forKey:@"sj"];
    WeakSelf;
    [CXAFNHttpRequestUtils httpPostRequest:[NSString stringWithFormat:@"%@%@",baseUrl,userActivityUpdateTargetUrl] withParamters:dict2 success:^(id responseData) {
        NSString *code = responseData[@"code"];
        
        [weakSelf stopLoading];
        
        if ([code isEqualToString:@"1000"]) {
            
            NSString *message = @"操作成功";
            if (weakSelf.currentAlertStatue==1000) {
                //未开始  显示开始按钮  将目标更新为开始状态
                message = @"小目标未开始";
                
            }else if (weakSelf.currentAlertStatue==1011||weakSelf.currentAlertStatue==1012) {
                //已开始  显示暂按钮  将目标更新为暂停
                message = @"小目标已开始";
                weakSelf.commitButton.hidden=NO;
                
            }else if (weakSelf.currentAlertStatue==1013) {
                //已暂住  显示继续按钮 将目标更新为继续
                message = @"小目标已暂停";
                
            }else if (weakSelf.currentAlertStatue==1014) {
                //已暂住  显示继续按钮 将目标更新为继续
                message = @"小目标已完成";
                weakSelf.commitButton.hidden=YES;
                
                if (appVersionCode>=18071318) {
                    NSString *statue=@"已成功";
                    NSInteger sta=1;
                    if (weakSelf.itemModel.plantime!=nil&&![weakSelf.itemModel.plantime isEqualToString:@""]) {
                        statue=@"已达标";
                        sta=2;
                        if (weakSelf.itemModel.useTime<weakSelf.useTotalTime*60*1000) {
                            statue= @"未达标";
                            sta=3;
                        }
                    }
                    
                    DLog(@"weakSelf.activityTagetEndTime is %ld",weakSelf.activityTagetEndTime);
                    
                    [weakSelf showFinishTargetPageFunction:weakSelf.activityTagetEndTime andWithUseTime:[[[SINACalendarUtils alloc]init]getMMSSFromSS:[NSString stringWithFormat:@"%ld",weakSelf.itemModel.useTime/1000]] andWithTargetStatue:statue andWithStatue:sta] ;
                }
                
            }
            //添加成功
            [YPXToastView showToastViewWithText:[NSString stringWithFormat:@"%@",message] andDuration:3 andParentView:weakSelf.view];
            weakSelf.itemModel.status = weakSelf.currentAlertStatue;
            [weakSelf updateTagerIconFunction];
            
            
        }else{
            NSString *message =responseData[@"message"];
            [YPXToastView showToastViewWithText:[NSString stringWithFormat: @"操作失败 %@" ,message] andDuration:3 andParentView:self.view];
        }
        
    } failure:^(NSError *error, NSInteger errCode) {
        
        [weakSelf stopLoading];
        [YPXToastView showToastViewWithText:@"操作失败 网络异常" andDuration:3 andParentView:self.view];
    }];
}
- (UIImage *)imageWithColor:(UIColor*) color
{
    CGRect rect=CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
    [self removeTimer];
    [self stopAnimation];
}

-(void)finishTargetFunction{
    DLog(@"完成小目标");
    
    NSString *endTime = [SINACalendarUtils currentTimeStr];
    self.activityTagetEndTime = [endTime integerValue];
    
    WISAlertView *alertView =  [[WISAlertView alloc]initWithTitle:@"提示" message:@"结束小目标？" sureBtn:@"确定" cancleBtn:@"取消"];
    alertView.resultIndex = ^(NSInteger index) {
        
        NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
        [dict setObject:self.itemModel.uuid forKey:@"uuid"];
        [dict setObject:[NSString stringWithFormat:@"%d",1014  ] forKey:@"status"];
        [dict setObject:endTime forKey:@"endtime"];
        [dict setObject:[NSString stringWithFormat:@"%ld",self.itemModel.useTime] forKey:@"pausetime"];
        [self removeTimer];
        self.currentAlertStatue = 1014;
        [self updateTargetTime:dict];
    };
    [alertView showXLAlertView];
}


- (void)startAnimationWithFlag:(NSInteger)flag

{
    
    CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    
    rotationAnimation.duration = 5;
    
    rotationAnimation.cumulative = YES;
    
    rotationAnimation.repeatCount = HUGE_VALF;
    if (flag==1) {
        [self.targetLevelCirBgImagView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    }else if (flag==2){
        [self.targetCirBgImagView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    }
    
    
    
}

//小目标完成弹框
//endTime 结束时间
//useTime 使用时间
//statue 状态
-(void)showFinishTargetPageFunction:(NSInteger)endTime andWithUseTime:(NSString*)useTime andWithTargetStatue:(NSString*) statue andWithStatue:(NSInteger)flag{
    SINAStuTargetFinishPopView *popView = [[SINAStuTargetFinishPopView alloc]init];
    popView.targetEndTime =[NSString stringWithFormat:@"%ld",endTime];
    popView.targetStatue=flag;
    popView.targetTitle=self.itemModel.title;
    if (self.itemModel.plantime!=nil&&![self.itemModel.plantime isEqualToString:@""]) {
        popView.targetUseTotalTime=self.itemModel.plantime;
    }else{
        popView.targetUseTotalTime=@"无";
    }
    popView.targetUseTime=useTime;
    
    [popView show];
}

- (void)stopAnimation

{
    [self.targetCirBgImagView.layer removeAllAnimations];
    [self.targetLevelCirBgImagView.layer removeAllAnimations];
    
}

- (void)dealloc
{
    
}
@end
